﻿using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class YCPlugin
{
	[DllImport ("__Internal")]
	private static extern string YCGetIDFA();

	[DllImport ("__Internal")]
	private static extern string YCGetIDFV();

	[DllImport ("__Internal")]
	private static extern bool YCIsSupportIpv4(string ipv4);

    [DllImport ("__Internal")]
	private static extern string YCGetIpv6(string ipv4);

	[DllImport ("__Internal")]
//	private static extern string AddSkipBackupAttributeToItemAtURL(string itemPath);
	private static extern void AddSkipBackupAttributeToItemAtURL(string path);
	/// <summary>
	/// 获取IDFA
	/// </summary>
	/// <returns>The IDF.</returns>
	public static string GetIDFA()
	{
		return YCGetIDFA ();
	}

	/// <summary>
	/// 获取IDFV
	/// </summary>
	/// <returns>The IDF.</returns>
	public static string GetIDFV()
	{
		return YCGetIDFV ();
	}

	/// <summary>
	/// 是否支持ipv4
	/// 如果只支持ipv6，返回false，否则返回true
	/// </summary>
	/// <returns><c>true</c> if is support ipv4 the specified ipv4; otherwise, <c>false</c>.</returns>
	/// <param name="ipv4">Ipv4.</param>
	public static bool IsSupportIpv4(string ipv4)
	{
		#if UNITY_IOS && !UNITY_EDITOR
		return YCIsSupportIpv4 (ipv4);
		#else
		return true;
		#endif
	}


    // ipv4->ipv6
	public static string GetIpv6(string ipv4)
	{
		#if UNITY_IOS && !UNITY_EDITOR
		return YCGetIpv6 (ipv4);
		#else
		return ipv4;
		#endif
	}
//	public static string IOSBackUP(string path)
//	{
//		return AddSkipBackupAttributeToItemAtURL (path);
//	}

	public static void IOSBackUP(string path)
	{
		Debug.Log ("YCPlugin IOSBackUP");
		AddSkipBackupAttributeToItemAtURL (path);
	}
}
